package flc.ast.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;

import flc.ast.R;
import flc.ast.databinding.DialogAddSkillBinding;
import stark.common.basic.base.BaseSmartDialog;

public class AddSkillDialog extends BaseSmartDialog<DialogAddSkillBinding> implements View.OnClickListener {

    public AddSkillDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.CENTER;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_add_skill;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvCancel.setOnClickListener(this);
        mDataBinding.tvConfirm.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tvCancel:
                dismiss();
                break;
            case R.id.tvConfirm:
                dismiss();
                if (!TextUtils.isEmpty(mDataBinding.etInput.getText().toString().trim())) {
                    if (listener != null) {
                        listener.clickRename(mDataBinding.etInput.getText().toString().trim());
                    }
                } else {
                    ToastUtils.showShort(R.string.please_input_professional_skill);
                }
                break;
            default:
                break;
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickRename(String skill);
    }
}
